#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
    string freqAlphabets(string s)
    {
        string ans;
        for (int i = 0; i < s.size(); ++i)
        {
            if (i + 2 < s.size() && s[i + 2] == '#')
            {
                ans += char((s[i] - '0') * 10 + (s[i + 1] - '1') + 'a');
                i += 2;
            }
            else
            {
                ans += char(s[i] - '1' + 'a');
            }
        }
        return ans;
    }

    string freqAlphabets_2(string s)
    {
        string ans;
        int sLen = s.length();
        for (int i = sLen - 1; i >= 0; i--)
        {
            if ('#' == s[i])
            {
                ans.push_back(stoi(s.substr(i - 2, i)) - 10 + 'j');
                i -= 2;
            }
            else
            {
                ans.push_back(s[i] - '1' + 'a');
            }
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};
int main()
{
    Solution s;
    string a="abbcdefghijklmnopqrstuvwxyz";
    string str =
        "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#";
    cout << s.freqAlphabets_2(str) << endl;
    system("pause");
    return 0;
}
